package top.wfzzq.dp.chain;

/**
 * 职责链管理者
 * 
 * @author wanghui
 *
 */
public class ChainManager {
	private MyChain head;
	private MyChain tail;

	public void add(MyChain chain) {
		if (head == null) {
			head = chain;
			tail = chain;
			return;
		}
		tail.setNext(chain);
		tail = chain;
	}

	public void show(String info) {
		// 处理职责链
		for (MyChain chain = head; chain != null; chain = chain.getNext()) {
			//职责
			chain.doChain(info);
		}
	}
}
